<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象的增强与解构</title>
</head>
<body>
    
</body>
<script>
    //对象的增强
    //es5 语法
    const person = {
        // 键值对
        name:'lyn', //属性
        age:18,
        //方法 es5语法
        run:function(){
            console.log('lyn在奔跑!')
        },

    }

    //es6 语法
    let height = 178
    const people = {
        height, // es6 语法

        speak(){//对象中方法的简写  es6语法
            console.log('lyn在说话!')
        }
    }

    //es 6语法 ...扩展符

    obj1 = {name:'lyn'}
    obj2 = {
        run(){
            console.log('奔跑');
            
        }
    }

    console.log({...obj1,...obj2});
    
    //对象的解构
    //什么是解构
    //快速从对象容器中提取成员的一种方式

    const obj3 = {
        name:'lyn',
        age:18,
        gender:'女'
    }

    //es5 
    //对象名.属性或者方法来提取值
    // var name = obj3.name;
    // var age = obj3.age;
    // var gender = obj3.gender;

    // console.log(name,age,gender);

    //es6
    // let {age,name,gender} = obj3;
    // console.log(gender,name,age);

    // 想要换名称，对象解构改属性方式用冒号
    let {age,name:newName,gender} = obj3
    console.log(newName,gender,age);
    
    
    




</script>
</html>